/*
 * Coordinate.java 2011. 5. 30.
 *
 * Copyright 2011 NHN Corp. All rights Reserved. 
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.naver.geotools;

public class Coordinate {
	public final double longitude;
	public final double latitude;

	public Coordinate(double longitude, double latitude) {
		this.longitude = longitude;
		this.latitude = latitude;
	}

	public float pan(Coordinate other) {
		double dx = other.longitude - longitude;
		double dy = other.latitude - latitude;
		double distance = Math.sqrt(dx * dx + dy * dy);
		if (distance == 0.0) {
			return 0.0F;
		}
		float degree = (float)(Math.acos(dy / distance) * 180.0 / 3.14);
		degree = (other.longitude > longitude) ? degree : -degree;
		if (degree < -180.00) {
			degree = -180.00F;
		} else if (degree > 180.00) {
			degree = 180.00F;
		}
		return degree;
	}
}
